import {
  createParamDecorator,
  SetMetadata,
  ExecutionContext,
  //组合装饰器
  applyDecorators,
} from '@nestjs/common';

import type { Request } from 'express';

//自定义装饰器，设置角色权限
export const Role = (...args: string[]) => SetMetadata('roles', args);

//参数装饰器，获取请求的url
export const ReqUrl = createParamDecorator(
  (data: string, ctx: ExecutionContext) => {
    const req = ctx.switchToHttp().getRequest<Request>();
    console.log(data);
    return req.url;
    // return applyDecorators(Role, xxx, xxx);
  },
);
